﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace AgvSystem.Web.Cross_Card_Info
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int Id=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(Id);
				}
			}
		}
			
	private void ShowInfo(int Id)
	{
		AgvSystem.BLL.Cross_Card_Info bll=new AgvSystem.BLL.Cross_Card_Info();
		AgvSystem.Model.Cross_Card_Info model=bll.GetModel(Id);
		this.lblId.Text=model.Id.ToString();
		this.txtCross_Card_Num.Text=model.Cross_Card_Num.ToString();
		this.chkIs_Crossed.Checked=model.Is_Crossed;
		this.txtCard_Num.Text=model.Card_Num.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtCross_Card_Num.Text))
			{
				strErr+="Cross_Card_Num格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtCard_Num.Text))
			{
				strErr+="Card_Num格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int Id=int.Parse(this.lblId.Text);
			int Cross_Card_Num=int.Parse(this.txtCross_Card_Num.Text);
			bool Is_Crossed=this.chkIs_Crossed.Checked;
			int Card_Num=int.Parse(this.txtCard_Num.Text);


			AgvSystem.Model.Cross_Card_Info model=new AgvSystem.Model.Cross_Card_Info();
			model.Id=Id;
			model.Cross_Card_Num=Cross_Card_Num;
			model.Is_Crossed=Is_Crossed;
			model.Card_Num=Card_Num;

			AgvSystem.BLL.Cross_Card_Info bll=new AgvSystem.BLL.Cross_Card_Info();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
